<template>
	<div class="container">
		<div class="jx-container">
      <div class="jx-table">
        <div class="title">
          <img class="icon" src="/static/img/icon-platform.png"/>
          机构列表
          <div class="add-new">
            <el-button class="jx-btn" type="primary" @click="addRow">新增机构</el-button>
          </div>
        </div>
        <el-table :data="list" border style="width: 100%" v-loading="boo.loading">
          <el-table-column type="index" label="序列" width="60" align="center">
            <template slot-scope="scope">
              <span>{{(scope.$index + 1) + ((params_list.page - 1) * params_list.size)}}</span>
            </template>
          </el-table-column>
          <el-table-column prop="img" label="类目图标" align="center" width="130">
            <template slot-scope="scope">
              <img v-if="scope.row.img" class="tb" :src="scope.row.img"/>
            </template>
          </el-table-column>
          <el-table-column prop="category_one" label="一级类目" align="center" :show-overflow-tooltip="true">
          </el-table-column>
          <el-table-column prop="img2" label="二级类目图标" width="130" align="center" :show-overflow-tooltip="true">
            <template slot-scope="scope">
              <img class="tb" :src="scope.row.img2"/>
            </template>
          </el-table-column>
          <el-table-column prop="category_two" label="二级类目" align="center" :show-overflow-tooltip="true">
          </el-table-column>
          <el-table-column prop="type" label="类别" align="center" :show-overflow-tooltip="true">
          </el-table-column>
          <el-table-column prop="shoptype" label="适用店铺类型" align="center" >
          </el-table-column>
          <el-table-column label="操作" width="210" align="center">
            <template slot-scope="scope">
              <el-button @click="viewRow(scope.row)" type="text" size="small">编辑</el-button>
              <el-button @click="deleteRow(scope.row)" type="text" size="small">删除</el-button>
              <el-button v-if="scope.row.category_one != ''" @click="addcategory(scope.row)" type="text" size="small">添加子类目</el-button>
            </template>
          </el-table-column>
        </el-table>
        <div v-if="list.length != 0" class="jx-pagination">
          <el-pagination @current-change="pageChange" @size-change="handleSizeChange" :current-page="params_list.page" :page-sizes="[10,50,100]" :page-size="params_list.size" layout="total, sizes, prev, pager, next, jumper"
            :total="other.allRow">
          </el-pagination>
        </div>
      </div>
    </div>
    <!-- 添加机构 -->
    <el-dialog  :visible.sync="boo.showDialog" class="jx-dialog" width="65%">
      <div slot="title" class="header-title">
        <span class="title-name">添加机构</span>
      </div>
      <div class="jx-detail">
        <div class="btn-container">
          <el-button class="jx-btn" type="warning" @click="boo.showDialog = false">取消</el-button>
          <el-button class="jx-btn" type="primary" :loading="boo.saveing" @click="submitRow">保存</el-button>
        </div>
      </div> 
    </el-dialog>
	</div>
</template>

<script>
  import list from 'static/json/setting/category.json'
	export default {
		data() {
			return {
        boo: {
          loading: false,
          showDialog: false,
        },
        other: {
          allRow: 1,
          saveing: false,
          img: '',
          img2: '',
        },
        list: list,
        currentRow: {},
        params_list: {
          page: 1,
          size: 10,
        },
			}
		},
		mounted(){
      let _self = this
      _self.getList()
    },
		methods: {
      getList(){
        let _self = this
      },
      pageChange(val){
        let _self = this
        _self.params_list.page = val
        _self.getList()
      },
      handleSizeChange(val) {
        let _self = this
        _self.params_list.size = val
        _self.getList()
      },
      addRow(){
        let _self = this
        _self.list.push({
          category_one: "",
          category_two: "",
          img: "",
          img2: "",
          shoptype: "",
          type: ""
        })
      },
      addcategory(){},
      viewRow(item){
        let _self = this
        // _self.boo.showDialog = true
        _self.currentRow = JSON.parse(JSON.stringify(item))
      },
      // 删除
      deleteRow(item){
        let _self = this
        
      },
      submitRow(formName){
      }
    }
	}

</script>
<style scoped lang="sass">
  .jx-table
    /deep/ .el-table__body td
      .cell
        height: auto
        line-height: auto
</style>
